// This code is purely written by Vaibhav...

import java.util.*;
import java.text.*;

class calender
{
	public static void main (String[] args) 
	{
		System.out.println(" You insert the date in format dd-mm-yyyy like 29-03-2009");
		System.out.println(" and this program will tell you the day like Monday!")	;
		
		int dd = getDay();   // Inputs 
		int mm = getMonth(); //	from the 
		int yy = getYear();  // User
		
		String date = dd+"-"+mm+"-"+yy; //convert the given date into a string.
		
		int n = calculate(dd,mm,yy); // Call the function calculate it will return
									// value between 0 to 7	
		
		String s = getWeekDay(n); 	// We pass the above number to get the day
		
		String t = getTense(yy);	// This will enhance the answer... by putting correct
							// tense. like "it is", "it was" or "it will be"
		
		System.out.print("\n \n On "+date+" it "+t/*tense is used here*/+" "+s);
	}
	
	// This function is used to put the correct tense in the answer.
	// It is not required to calculate date. It's extra
	static String getTense(int yy)
	{
		Calendar c = Calendar.getInstance();
		int today = c.get(Calendar.YEAR);
		String s = null;
		if(yy==today)
			s = "is";
		else
		{
			if(yy>today)
				s = "will be";
			else
				s = "was";
		}
		return s;
	}	
	
	// This functions returns day in words
	static String getWeekDay(int n)
	{
		String s = "Blank";
		switch (n)
		{
			case 0: s = "Sunday"; // code for sunday
				break;
			case 1: s = "Monday";
				break;
			case 2: s = "Tuesday";
				break;
			case 3: s = "Wednesday";
				break;
			case 4: s = "Thurday";
				break;
			case 5: s = "Friday";
				break;
			case 6: s = "Saturday";
				break;
			case 7: s = "Sunday"; //  7, 14, 21... multiples of same number can be possible codes
				break;
			default: System.out.print(" Error! ");
				break;
		}
		return s;
	}
	
	
	// This function returns a code for the day. It is a integer value between 0 to 7
	static int calculate(int dd, int mm, int yy)
	{
		int n = 0;
		System.out.print("\n The Date you Entered is: "+dd+"-"+mm+"-"+yy);
		
		int m = getMonthCode(mm,yy); // Month Code is set
		int y = (yy%100); // get last two digits
		int x = yy/100; // get first two digits
		// formula is 
		// 		day + month_code + last two digits of year + (year / 4) + 19th century code
		//e.g.  29  +  march = 02 +  89 + (89/4) + 1
		// = 143 divide by seven only consider integer part u get 3 which is code for wednesday
		switch(x)
		{
			case 17: n = dd+m+y+(y/4)+5; //formula for calculating day
				break;
			case 18: n = dd+m+y+(y/4)+3; // if year is in between 1800-1899
				break;
			case 19: n = dd+m+y+(y/4)+1; // if year is in between 1900-1999
				break;
			case 20: n = dd+m+y+(y/4); // for 2000 - 2099
				break;
			default: System.out.println(" Error! ");
				break;
		}
		
		do
		{
			n = n-7;
		}while(n>7);
		
		return n;
	}
	
	// we have month code for every month we add that code in the above eqation.
	static int getMonthCode(int mm, int yy)
	{
		int m = 0;
		switch(mm)
		{
			case 01: m = 06; // Jan
						break;
			case 02: m = 02; // Feb
						break;
			case 03: m = 02; // Mar
						break;
			case 04: m = 05; // Apr
						break;
			case 05: m = 07; // May
						break;
			case 06: m = 03; // Jun
						break;
			case 07: m = 05; // Jul
						break;
			case 8: m = 01; // Aug
						break;
			case 9: m = 04; // Sep
						break;
			case 10: m = 06; // Oct
						break;
			case 11: m = 02; // Nov
						break;
			case 12: m = 04; // Dec
						break;
			default: System.out.println(" Error! ");
						break;
		}
		
		//Leap year adjustment
		int y = (yy%100);
		
		if(mm<03)
		{
			if(y%4==0)
			{
				System.out.print("\n \n "+yy+" = Leap year");
				if(mm==1)
					m = 05;
				else
					m = 01;
			}
		}
		
		return m;
	}
		
	static int getDay()
	{
		System.out.print("\n \n Please Enter the Day: dd = ");
		int dd = getInt();
		while(dd>31||dd<1)
		{
			System.out.print(" \n Invalid Date! Enter a vaild Day = ");
			dd = getInt();
		}
		return dd;
	}
	
	static int getMonth()
	{
		System.out.print("\n Please Enter the Month: mm = ");
		int mm = getInt();
		while(mm<1||mm>12)
		{
			System.out.print(" \n Invalid Date! Enter a vaild Month = ");
			mm = getInt();
		}
		return mm;
	}
	static int getYear()
	{
		System.out.print("\n Please Enter the Year: yy = ");
		int yy = getInt();
		while(yy<1600||yy>2099)
		{
			System.out.print(" \n Invalid Date! Enter a vaild Year = ");
			yy = getInt();
		}
		return yy;
	}
	
	static int getInt()
	{
		Scanner k = new Scanner(System.in);
		int x = k.nextInt();
		return x;
	}
	
	//static String getDay(int n) // This method will return day
}